fnc_menu_main = {
	_ok = createDialog "menuDlg";

	/* Fill out the labels to show balance, primary and secondary weapons plus their magazine counts */
	_weapons = [] call fnc_player_getWeapons;
	_primaryWeapon = "None";
	_secondaryWeapon = "None";
	_magazines = [0,0];

	if !((_weapons select 0) == "") then {
		_primaryWeapon = getText (configFile >> "CfgWeapons" >> _weapons select 0 >> "displayname");
		_magazine = getArray (configFile >> "CfgWeapons" >> (_weapons select 0) >> "magazines") select 0;

		_pref = [_weapons select 0, 0, prefMags] call fnc_search_array;
		if (_pref >= 0) then {
			_magazine = (prefMags select _pref) select 1;
		};

		_magazines = [{ _x == _magazine } count magazines player, 0];
	};

	if (count _weapons > 1) then {
		_secondaryWeapon = getText (configFile >> "CfgWeapons" >> _weapons select 1 >> "displayname");
		_magazine = getArray (configFile >> "CfgWeapons" >> (_weapons select 1) >> "magazines") select 0;
		_magazines = [_magazines select 0, { _x == _magazine } count magazines player];
	};

	ctrlSetText [10001, format["Primary weapon: %1", _primaryWeapon]];
	ctrlSetText [10002, format["Secondary weapon: %1", _secondaryWeapon]];
	ctrlSetText [10003, format["Balance: %1$", player getVariable "money"]];
	ctrlSetText [10004, format["Primary magazines: %1", _magazines select 0]];
	ctrlSetText [10005, format["Secondary magazines: %1", _magazines select 1]];
};

fnc_menu_buy = {
	(_this) call fnc_buy_weapon;
	[] call fnc_menu_main;
};

fnc_menu_pistols = {
	_ok = createDialog "pistolDlg";
};

fnc_menu_shotguns = {
	_ok = createDialog "shotgunDlg";
};

fnc_menu_smgs = {
	_ok = createDialog "smgDlg";
};

fnc_menu_rifles = {
	_ok = createDialog "riflesDlg";
};

fnc_menu_other = {
	_ok = createDialog "otherDlg";
};
